package com.hz.pro.kitchen.enums;

/**
 * 错误码枚举类
 * 102018xx可以直接抛给外部业务显示（与收银台约定）
 */
public enum ErrorCodeEnum {

    UNKNOWN(10201000,"未知错误"),
    SYSTEM_EXCEPTION(10201001, "系统异常"),
    ILLEGAL_ARGUMENT(10201002, "非法参数"),
    SIGN_VERIFY_ERROR(10201003, "验签失败"),
    ALIPAY_REQUEST_EXCEPTION(10201004, "支付宝发起请求异常"),
    ALIPAY_REQUEST_ERROR(10201005, "支付宝发起请求错误"),
    DUPLICATE_PAY_REQUEST(10201006, "订单已支付"),
    DUPLICATE_REQUEST(10201006, "重复提交请求"),
    ILLEGAL_RESPONSE(10201007, "接口返回数据非法"),
    UNION_CERT_INIT_EXEC(10201008, "银联证书配置错误"),
    DATA_QUERY_ERROR(10201009, "数据查询异常"),
    SIGN_EORROR(10201010, "签名异常"),
    PAY_DATA_NOT_EXISTS(10201011, "支付记录不存在"),
    RESPONSE_BODY_EMPTY(10201012, "返回报文为空"),
    TRANSFER_STATUS_ERROR(10201013, "转账状态异常"),
    TRANSFER_ALIPAY_ERROR(10201014, "支付宝转账异常"),
    CUSTOM_DECLARE_FAIL(10201015, "报关失败"),
    REFUND_MONEY_ERROR(10201016, "退款金额非法"),
    REFUND_DATA_NOT_EXISTS(10201017, "退款记录不存在"),
    REFUND_STATUS_ERROR(10201018, "退款状态异常"),
    REFUND_FAIL(10201019, "退款失败"),
    ACCOUNTING_EXCEPTION(10201020, "账务中心服务调用失败"),
    USER_OPER_BUSY(10201021, "操作频繁，请稍候重试"),
    LLPAY_CERT_INIT_EXEC(10201022, "连连支付证书配置错误"),
    PAGE_ERROR(10201023, "分页参数未配置"),
    WEIXIN_ALLINPAY_CERT_INIT_EXEC(10201024, "通联微信支付证书配置错误"),
    CALLBACK_QUERY_STATUS_NOT_MATCH(10201025, "交易查询状态与异步通知不一致"),
    LENDING_STATUS_ERROR(10201026, "放款状态异常"),
    XML_CONVERT_EXCEPTION(10201027, "xml转换异常"),
    ALLINPAY_CERT_INIT_EXEC(10201028, "通联支付证书配置错误"),
    LENDING_RECORD_NOT_EXIST(10201029, "放款记录不存在"),
    BANK_CARD_EXIST(10201030, "卡号已绑定"),
    BANK_NO_NOT_MATCH(10201031, "卡号与所选银行不匹配"),
    CREDIT_NOT_SUPPORT(10201032, "当前业务不支持信用卡"),
    LLPAY_BIND_CARD_EXCEPTION(10201033, "银行卡鉴权请求失败"),
    LLPAY_UN_BIND_CARD_EXCEPTION(10201034, "银行卡解除签约请求失败"),
    SUNSHINEPAY_CERT_INIT_EXEC(10201035, "阳光小贷支付配置错误"),
    BANK_CARD_NOT_EXIST(10201036, "银行卡不存在"),
    BANK_CARD_USER_NOT_MATCH(10201037, "银行卡用户信息不匹配"),
    BANK_CARD_LOG_NOT_EXIST(10201038, "银行卡记录不存在"),
    ORDER_NO_USER_NOT_MATCH(10201039, "订单用户信息不匹配"),
    SMS_CODE_SENDTIMES_OVERFLOW(10201040, "短信发送过于频繁，请稍后再试"),
    LLPAY_ENCRYPT_EXCEPTION(10201041, "连连工具包加密失败"),
    CUSTOM_DECLARE_ERROR(10201042, "报关失败，请稍候重试"),

    // 102018xx可以直接抛给外部业务显示（与收银台约定）
    PAY_CONFIG_ERROR(10201801, "支付配置异常"),
    PAY_PASSWORD_ERROR(10201802, "密码输入错误"),
    PAY_PASSWORD_CHECK_EXCEPTION(10201803, "密码校验失败，请稍候重试"),
    CHARGE_BANK_CONFIG_ERROR(10201804, "充值银行未配置"),
    CARD_NOT_EXIST_ERROR(10201805, "输入的卡号不存在或有误，请检查"),
    QUERY_CARD_TYPE_EXCEPTION(10201806, "获取卡类型异常"),
    LLPAY_CREATE_BILL_EXCEPTION(10201807, "连连支付下单请求失败"),
    BALANCE_PAY_EXCEPTION(10201808, "钱包余额支付失败"),
    ONLY_CHINESE_ID_SUPPORT(10201809, "暂只支持身份证用户充值"),

    CHANNEL_SERVICE_CALL_FAILURE(10201810, "金融渠道服务调用失败"),

    // 102019xx错误码直接抛给交易渠道
    CUSTOMDECLARE_TRADE_STATUS_ERROR(10201901,"支付宝报关-交易状态不合法，不允许报关"),
    CUSTOMDECLARE_PAYER_CERT_INFO_ILLEGAL(10201902,"支付宝报关-支付人身份信息异常"),
    CUSTOMDECLARE_TRADE_NOT_EXIST(10201903,"支付宝报关-交易不存在"),
    CUSTOMDECLARE_INVALID_PARAMETER(10201904,"支付宝报关-参数不合法"),
    CUSTOMDECLARE_CONTEXT_INCONSISTENT(10201905,"支付宝报关-同一笔请求参数不一致"),
    CUSTOMDECLARE_SAME_CUSTOMS_DECLARE_ONCE(10201906,"支付宝报关-同一笔交易同一个海关只能报关一次"),
    CUSTOMDECLARE_REQUEST_AMOUNT_EXCEED(10201907,"支付宝报关-金额超限"),
    CUSTOMDECLARE_PARTNER_ERROR(10201908,"支付宝报关-交易partner跟报关请求partner不一致"),
    CUSTOMDECLARE_PAYER_ENABLE_STATUS_FORBID(10201909,"支付宝报关-报关交易支付人状态非法"),

    ;

    private int code;
    private String message;

    private ErrorCodeEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public static ErrorCodeEnum parse(int code){
        for(ErrorCodeEnum codeEnum : values()){
            if(code == codeEnum.getCode()){
                return codeEnum;
            }
        }
        return UNKNOWN;
    }
}
